﻿using HZY.Host.Admin.ApplicationServices.Systems;
using HZY.Host.Admin.Models.Dtos.Systems;

namespace HZY.Host.Admin.Controllers.Systems;

/// <summary>
/// 系统账号管理
/// </summary>
[ControllerDescriptor(MenuId = "15", DisplayName = "系统账号")]
public class SysUserController(IServiceProvider serviceProvider)
    : AdminControllerBase<SysUserService, SysUser, Guid, SysUser, SysUserFormDto>(serviceProvider)
{
    /// <summary>
    /// 获取用户信息
    /// </summary>
    /// <returns></returns>
    [ActionDescriptor(DisplayName = "获取当前用户信息")]
    [ApiResourceCacheFilter(20)]
    [HttpGet(Name = "info")]
    public async Task<AccountContext> GetUserInfoAsync()
    {
        var accountContext = await Service.GetUserInfoAsync();
        if (accountContext == null)
        {
            throw MessageBox.CreateMessage(R.Unauthorized);
        }

        return accountContext;
    }
}